package ExerciseOne;

public class Account {

	private int id;//账号
	private double balance;//余额
	private double annualInterestRate;//年利率
	
	public Account()
	{
		
	}
	public Account(int id,double balance,double annualInterestRate)
	{
		this.id = id;
		this.balance = balance;
		this.annualInterestRate = annualInterestRate;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public double getBalance() {
		return balance;
	}
	public void setBalance(double balance) {
		this.balance = balance;
	}
	public double getAnnualInterestRate() {
		return annualInterestRate;
	}
	public void setAnnualInterestRate(double annualInterestRate) {
		this.annualInterestRate = annualInterestRate;
	}
	
	//返回月利率
	public double getMonthlyInterest()
	{
		return annualInterestRate/12.0;
	}
	
	//取钱方法
	public void withdraw(double amount)
	{
		if(amount>balance)
		{
			System.out.println("取钱失败，余额不足");
			return;
		}
		else
		{
			balance-=amount;
			System.out.println("取钱成功，余额为："+balance);
		}
	}
	
	//存钱方法
	public void deposit(double amount)
	{
		if(amount>0)
		{
			balance+=amount;
			System.out.println("存钱成功，余额为："+balance);
		}
		else
		{
			System.out.println("存钱失败");
		}
	}
}
